<%# Copyright 2009 Swansea University

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
%>

<% title "All Projects" %>


<% content_for :head do %>
  <%= render(:partial => "shared/import_tablesorter") %>
  <script type="text/javascript">
    $(document).ready(function() {
      $("#projects")
      .tablesorter({sortList: [[2, 0]], widthFixed: true, widgets: ['zebra']})
      .tablesorterPager({container: $("#pager"), positionFixed: false});
    });
  </script>
<% end %>

<%= render(:partial => "navigation") %>

<% slogan "&ldquo;Vorsprung durch Technik&rdquo; (Progress through technology) &ndash; Audi avertising slogan." %>

<p>This page shows all the projects that have been set this year.</p>
<p>The data in the table below can be sorted by clicking on the
table headings. For example, to sort by research centre, click on the <em>Research Centre</em> column. To reverse the sort order, click again.</p>
<p>Note because there are such a large number of projects, this table has a paging control at the bottom.
This allows you to move through the project list page by page.
In order left-to right, the small icons on the left move to the first page and previous page; the text field
in the centre shows the page number and number of pages;
the icons on the right move left and to the last page resepctively.</p>
<p>You can adjust the number of projects that are shown on one page by selecting the paging size in the drop-down list
at the right of the pager control. If you visit one of the projects from this page, the <em>back</em> link should return you to the
same point in the table.</p>

<table id="projects" class="tablesorter">
  <thead>
    <th title="Click to sort by project number: click again to reverse sort direction.">Number</th>
    <th title="Click to sort by project title: click again to reverse sort direction.">Title</th>
    <th title="Click to sort by project supervisor: click again to reverse sort direction.">Supervisor</th>
    <th title="Click to sort by research centre: click again to reverse sort direction.">Centre</th>
    <%= add_selection_to_table_header_if(@project_selection) %>
  </thead>
  <% if @project_selection %>
    <% form_for (@project_selection) do |f| %>
      <tfoot>
        <tr><th colspan="3">&nbsp;</th><th colspan="2"><%= f.submit "Update selections"  %></th></tr>
      </tfoot>
      <tbody>
        <tr><th>PS ID</th><td><%= @project_selection.id %></td></tr>
        <%= render(:partial => "project_selection_index", :collection => @projects, :locals => {:f => f, :selection => @project_selection}) %>
      </tbody>
    <% end %>
  <% else %>
    <tfoot>
      <th>Number</th>
      <th>Title</th>
      <th>Supervisor</th>
      <th>Centre</th>
    </tfoot>
    <tbody>
      <%= render(:partial => "project_index", :collection => @projects) %>
    </tbody>
  <% end %>
</table>
<%= render(:partial => "shared/tablesorter_pager", :locals => {:pager_id => 'pager'})%>
